// ==UserScript==
// @name       red-time-plugin
// @namespace  npm/vite-plugin-monkey
// @version    0.0.0
// @author     nickname:cc,email:402737184@qq.com
// @icon       https://vitejs.dev/logo.svg
// @match      https://buyin.jinritemai.com/dashboard/marketing/red-envelope
// @require    https://cdn.jsdelivr.net/npm/vue@3.4.19/dist/vue.global.prod.js
// @grant      GM_addStyle
// ==/UserScript==

(t=>{if(typeof GM_addStyle=="function"){GM_addStyle(t);return}const e=document.createElement("style");e.textContent=t,document.head.append(e)})(" .red-time-plugin-container[data-v-7599a7a4]{position:fixed;bottom:0;left:0;z-index:999999;background-color:bisque;padding:10px;font-size:14px;input[data-v-7599a7a4] {width: 50px; color: red; font-size: 14px;}} ");

(function (vue) {
  'use strict';

  const _hoisted_1 = { class: "red-time-plugin-container" };
  const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({
    __name: "plugin",
    setup(__props) {
      const timeGap = vue.ref(6);
      setInterval(() => {
        const footerDom = document.querySelector(".buyin-picker-footer");
        console.log("footerDom", footerDom);
        if (footerDom && timeGap.value > 0) {
          const endTime = new Date(Date.now() + timeGap.value * 60 * 1e3);
          const year = endTime.getFullYear();
          const month = endTime.getMonth() + 1;
          const date = endTime.getDate();
          const hours = endTime.getHours();
          const minutes = endTime.getMinutes();
          const seconds = endTime.getSeconds();
          const btnDom = document.querySelector(".buyin-picker-footer button");
          console.log("btnDom", btnDom);
          btnDom.style.display = "none";
          console.log("timeDom", `td[title='${year}-${month < 10 ? `0${month}` : month}-${date < 10 ? `0${date}` : date}']`);
          const timeDom = document.querySelector(`td[title='${year}-${month < 10 ? `0${month}` : month}-${date < 10 ? `0${date}` : date}']`);
          console.log("timeDom", timeDom);
          timeDom.click();
          const hoursDom = document.querySelectorAll(".buyin-picker-time-panel-column")[0].children[hours];
          console.log("hoursDom", hoursDom);
          hoursDom.click();
          const minutesDom = document.querySelectorAll(".buyin-picker-time-panel-column")[1].children[minutes];
          console.log("minutesDom", minutesDom);
          minutesDom.click();
          const secondsDom = document.querySelectorAll(".buyin-picker-time-panel-column")[2].children[seconds];
          console.log("secondsDom", secondsDom);
          secondsDom.click();
          btnDom.click();
        } else if (footerDom && timeGap.value == 0) {
          const btnDom = document.querySelector(".buyin-picker-footer button");
          btnDom.style.display = "block";
        }
      }, 500);
      return (_ctx, _cache) => {
        return vue.openBlock(), vue.createElementBlock("div", _hoisted_1, [
          vue.createTextVNode(" 红包有效期："),
          vue.withDirectives(vue.createElementVNode("input", {
            "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => timeGap.value = $event)
          }, null, 512), [
            [
              vue.vModelText,
              timeGap.value,
              void 0,
              { number: true }
            ]
          ]),
          vue.createTextVNode("分钟 ")
        ]);
      };
    }
  });
  const _export_sfc = (sfc, props) => {
    const target = sfc.__vccOpts || sfc;
    for (const [key, val] of props) {
      target[key] = val;
    }
    return target;
  };
  const RedTimePlugin = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-7599a7a4"]]);
  const _sfc_main = /* @__PURE__ */ vue.defineComponent({
    __name: "App",
    setup(__props) {
      return (_ctx, _cache) => {
        return vue.openBlock(), vue.createBlock(RedTimePlugin);
      };
    }
  });
  vue.createApp(_sfc_main).mount(
    (() => {
      const app = document.createElement("div");
      document.body.append(app);
      return app;
    })()
  );

})(Vue);